package com.meichis.yndms.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.meichis.mcsappframework.adapter.recyclerview.CommonAdapter;
import com.meichis.mcsappframework.adapter.recyclerview.base.ViewHolder;
import com.meichis.yndms.R;
import com.meichis.yndms.common.MCode;
import com.meichis.yndms.model.VstTravel;
import com.meichis.yndms.ui.activity.ClientDetailActivity;

import java.util.List;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-07-19 15:14
 */
public class VstTravelAdapter extends CommonAdapter<VstTravel> {

    public VstTravelAdapter(Context context, int layoutId, List<VstTravel> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder holder, VstTravel vstTravel, int position) {
        holder.getView(R.id.tv_TopLine).setVisibility(View.VISIBLE);

        if (position == 0) {
            holder.setBackgroundRes(R.id.tv_dot, R.drawable.shape_circle_theme);
            holder.getView(R.id.tv_TopLine).setVisibility(View.INVISIBLE);
        } else if (position == mDatas.size() - 1) {
            holder.getView(R.id.tv_bottomLine).setVisibility(View.INVISIBLE);
        }

        holder.setText(R.id.tv_title, vstTravel.getTerminalName());
        holder.setText(R.id.tv_content, vstTravel.getStrIDate());
        holder.setOnClickListener(R.id.tv_title,v -> {
            Intent intent = new Intent(mContext, ClientDetailActivity.class);
            intent.putExtra(MCode.DMSID,vstTravel.getTerminalIBMID());
            mContext.startActivity(intent);
        });
    }

}
